package com.queming.music.mapper;

import com.queming.core.mapper.FileMapper;
import com.queming.core.mapper.MapperInterface;
import com.queming.music.dto.AlbumCreateRequest;
import com.queming.music.dto.AlbumDto;
import com.queming.music.dto.AlbumUpdateRequest;
import com.queming.music.entity.Album;
import com.queming.music.vo.AlbumVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.NullValuePropertyMappingStrategy;

/**
 * @author chencidiao
 * @date 2022/05/11 21:53
 **/

@Mapper(componentModel = "spring" ,uses = {FileMapper.class,ArtistMapper.class,MusicMapper.class},nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS,
        nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public interface AlbumMapper extends MapperInterface<Album, AlbumDto> {

    @Mapping(source = "coverId",target = "cover.id")
    @Mapping(source = "artistIds",target = "artists")
    AlbumDto toDto(AlbumCreateRequest albumCreateRequest);

    @Mapping(source = "coverId",target = "cover.id")
    @Mapping(source = "artistIds",target = "artists")
    AlbumDto toDto(AlbumUpdateRequest albumUpdateRequest);


    AlbumVo toVo(AlbumDto albumDto);
}
